from bs4 import BeautifulSoup

if __name__ == '__main__':
    # 将本地的html文档中的数据加载到该对象中
    fp = open('./test.html', 'r', encoding='utf-8')
    soup = BeautifulSoup(fp, 'lxml')
    # print(soup)
    # print(soup.a)   # soup.tagName 返回的事html中第一次出现的tagName
    # print(soup.div)
    # print(soup.find('div'))     # print(soup.div)
    # print(soup.find('div', class_='song'))
    # print(soup.find_all('a'))
    # print(soup.select('.tang')) # 选择器？ .代表类？
    # print(soup.select('.tang > ul > li > a')[0])
    # print(soup.select('.tang > ul  a')[0])
    # print(soup.select('.tang > ul  a')[0].text) # .string .get_text()
    # print(soup.find('div', class_='song').string)
    print(soup.select('.tang > ul  a')[0]['href'])

